<?php

class Core_Backend_Component_Resource_View_Account_Poi_List extends Core_Backend_Share_View_Grid {

    protected function buildToolbar($toolbar) {
    	$group = $toolbar->createGroup('back');
        $group->addLink($this->getHistoryUrl('resource/account/index'), $this->__('share.button.back'));
        parent::buildToolbar($toolbar);
        $toolbar->removeGroup('filter');
        $group = $toolbar->createGroup();
        $group->addLink($this->getUrl(array('accountid'=>$this->getAccount()->getId()), 'poi-assign'), $this->__('share.button.assign'));
        $group->addLink($this->getUrl(array('accountid'=>$this->getAccount()->getId()), 'poi-import'), $this->__('share.button.import'));
        $group = $toolbar->createGroup('delete');
        $group->addButton($this->__('share.button.delete'))
                    ->bindEvent('click', "submitGridChecked('" . $this->getGrid()->getId() . "', '" . $this->getUrl(array('accountid'=>$this->getAccount()->getId()), 'poi-delete') . "')");
    }

    public function buildGrid($grid) {
        $grid->setId('poi_grid')->setPrimaryKey('id');
        $grid->addLabelColumn($this->__('share.label.poi'), 'poi', '{shop_name}');
        $grid->addDatetimeColumn($this->__('share.label.start_time'), 'start_time', '{assign_start_time}')
                ->setWidth(120);
        $grid->addDatetimeColumn($this->__('share.label.end_time'), 'end_time', '{assign_end_time}')
                ->setWidth(120);
        $grid->addDatetimeColumn($this->__('resource.label.assigned_time'), 'assigned_time', '{assigned_time}')
                ->setWidth(120);
        $grid->addLabelColumn($this->__('resource.label.assigner'), 'assinger', '{assigner_name}')
                ->setWidth(80);
        $grid->addLinkColumn('#', 'edit', $this->getUrl(array('accountid' => '{account_id}', 'poiid'=>'{id}'), 'poi-edit'), $this->__('share.button.edit'))
                ->setWidth(40)
                ->setAlign('center');
        $grid->setDataSource($this->getList()->toArray());
        parent::buildGrid($grid);
    }
}